From ff8397064259273f693f619a75580fe824ed0a77 Mon Sep 17 00:00:00 2001 From: Taku Kudo Date: Wed, 3 Aug 2022 12:45:31 +0900 Subject: [PATCH] Adds SWIGPYTHON flag Signed-off-by: Kentaro Hayashi Gbp-Pq: Name 0014-Adds-SWIGPYTHON-flag.patch --- python/setup.py | 3 ++- python/src/sentencepiece/__init__.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/python/setup.py b/python/setup.py index fdf9394..3438ddd 100755 --- a/python/setup.py +++ b/python/setup.py @@ -96,6 +96,7 @@ class build_ext(_build_ext): else: cflags.append('-Wl,-strip-all') libs.append('-Wl,-strip-all') + cflags.append('-DSWIGPYTHON') print('## cflags={}'.format(' '.join(cflags))) print('## libs={}'.format(' '.join(libs))) ext.extra_compile_args = cflags @@ -115,7 +116,7 @@ if os.name == 'nt': '..\\build\\root_{}\\lib\\sentencepiece_train.lib'.format(arch) ] else: - cflags = ['/std:c++17', '/MT', '/I..\\build\\root\\include'] + cflags = ['/std:c++17', '/MT', '/I..\\build\\root\\include', '/DSWIGPYTHON'] libs = [ '..\\build\\root\\lib\\sentencepiece.lib', '..\\build\\root\\lib\\sentencepiece_train.lib' diff --git a/python/src/sentencepiece/__init__.py b/python/src/sentencepiece/__init__.py index 07acb94..2a91022 100644 --- a/python/src/sentencepiece/__init__.py +++ b/python/src/sentencepiece/__init__.py @@ -126,7 +126,7 @@ class ImmutableSentencePieceText(object): return self.SerializeAsString() == other.SerializeAsString() def __hash__(self): - return hash(self.SerializeAsString()) + return hash(self.SerializeAsString()) # Register ImmutableSentencePieceText in _sentencepiece: -- 2.30.2